//
//  YDMineControllerUnLoginTopView.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2017/11/13.
//  Copyright © 2017年 LK-IOS. All rights reserved.
//

#import "YDMineControllerUnLoginTopView.h"

@interface YDMineControllerUnLoginTopView()

//背景图片
@property (nonatomic , weak) UIImageView *backImage;
//标题
@property (nonatomic , weak) UILabel *titleLabel;
//用户头像
@property (nonatomic , weak) UIImageView *iconImageView;

//账户余额
@property (nonatomic , weak) UILabel *accountLabel;
//账户余额
@property (nonatomic , weak) UIImageView *accountNumberImage;

//充值按钮
@property (nonatomic , weak) SYNoHeightedButton *loginButton;
//提现按钮
@property (nonatomic , weak) SYNoHeightedButton *registerButton;




@end

@implementation YDMineControllerUnLoginTopView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.userInteractionEnabled = YES;
        
        [self backImage];
        [self titleLabel];
        [self iconImageView];
        [self accountLabel];
        [self accountNumberImage];
        [self loginButton];
        [self registerButton];

        
        
        
    }
    return self;
}


/*****背景图片******/
-(UIImageView *)backImage
{
    if (_backImage == nil) {
        UIImageView *backImage = [[UIImageView alloc] init];
        [self addSubview:backImage];
        backImage.image = [UIImage imageNamed:@"wode-bg-yd"];
        backImage.contentMode = UIViewContentModeScaleAspectFill;
        [backImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.top.equalTo(self);
        }];
        _backImage = backImage;
    }
    return _backImage;
}
/*****标题******/
-(UILabel *)titleLabel
{
    if (_titleLabel == nil) {
        UILabel *titleLabel = [[UILabel alloc] init];
        [self addSubview:titleLabel];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.textColor = [UIColor whiteColor];
        titleLabel.font = [UIFont systemFontOfSize:font20ScreenWRate * LKScreenW];
        titleLabel.text = @"我的";
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            if (isPhoneX) {
                make.top.equalTo(self).offset(rateX812(37));
            }else{
                make.top.equalTo(self).offset(rate750(27));
            }
            
        }];
        
        _titleLabel = titleLabel;
    }
    return _titleLabel;
}

/*****用户头像******/
-(UIImageView *)iconImageView
{
    if (_iconImageView == nil) {
        UIImageView *iconImageView = [[UIImageView alloc] init];
        [self addSubview:iconImageView];
        iconImageView.image = [UIImage imageNamed:@"mine-touxiang-weidenglu"];
        [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.height.width.equalTo(@(rate375(60)));
            if (isPhoneX) {
                make.top.equalTo(self.titleLabel.mas_bottom).offset(rateX812(22));
            }else{
                make.top.equalTo(self.titleLabel.mas_bottom).offset(rate750(22));
            }
        }];
        iconImageView.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick)];
        [iconImageView addGestureRecognizer:tap];
        iconImageView.layer.cornerRadius = rate375(60) * 0.5;
        iconImageView.layer.masksToBounds = YES;
        
        _iconImageView = iconImageView;
    }
    return _iconImageView;
}

-(void)tapClick
{
    if ([self.delegate respondsToSelector:@selector(mineControllerUnLoginTopView:clickStyle:)]) {
        [self.delegate mineControllerUnLoginTopView:self clickStyle:SYMineUnLoginTopViewIcon];
    }
}


//*********账户余额*************/
-(UILabel *)accountLabel
{
    if (_accountLabel == nil) {
        UILabel *accountLabel = [[UILabel alloc] init];
        [self addSubview:accountLabel];
        accountLabel.textAlignment = NSTextAlignmentCenter;
        accountLabel.textColor = DRJAlphaColor(255, 255, 255, 0.7);
        accountLabel.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        accountLabel.text = @"账户余额";
        [accountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            if (isPhoneX) {
                make.top.equalTo(self.iconImageView.mas_bottom).offset(rateX812(16));
            }else{
                make.top.equalTo(self.iconImageView.mas_bottom).offset(rate750(16));
            }
            
        }];
        _accountLabel = accountLabel;
    }
    return _accountLabel;
}
//*********账户余额数值*************/
-(UIImageView *)accountNumberImage
{
    if (_accountNumberImage == nil) {
        UIImageView *accountNumberImage = [[UIImageView alloc] init];
        [self addSubview:accountNumberImage];
        accountNumberImage.backgroundColor = [UIColor clearColor];
        accountNumberImage.image = [UIImage imageNamed:@"mineAccountImage"];
        [accountNumberImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            if (isPhoneX) {
                make.top.equalTo(self.accountLabel.mas_bottom).offset(rateX812(14));
            }else{
                make.top.equalTo(self.accountLabel.mas_bottom).offset(rate750(14));
            }
        }];
        _accountNumberImage = accountNumberImage;
    }
    return _accountNumberImage;
}


//*********登录按钮*************/
-(SYNoHeightedButton *)loginButton
{
    if (_loginButton == nil) {
        SYNoHeightedButton *loginButton = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:loginButton];
        loginButton.backgroundColor = [UIColor colorWithHexString:Orange];
        [loginButton setTitle:@"登录" forState:UIControlStateNormal];
        [loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        loginButton.titleLabel.font = [UIFont systemFontOfSize:font16ScreenWRate * LKScreenW];
        loginButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        [loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.mas_centerX).offset(-rate375(10));
            make.width.equalTo(@(rate375(120)));
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(32)));
                make.top.equalTo(self.iconImageView.mas_bottom).offset(rateX812(81));
            }else{
                make.height.equalTo(@(rate750(32)));
                make.top.equalTo(self.iconImageView.mas_bottom).offset(rate750(81));
            }
        }];
        loginButton.layer.cornerRadius = 3.0;
        loginButton.layer.masksToBounds = YES;
        [loginButton addTarget:self action:@selector(loginButtonClick) forControlEvents:UIControlEventTouchDown];
        _loginButton = loginButton;
    }
    return _loginButton;
}
-(void)loginButtonClick
{
    if ([self.delegate respondsToSelector:@selector(mineControllerUnLoginTopView:clickStyle:)]) {
        [self.delegate mineControllerUnLoginTopView:self clickStyle:SYMineUnLoginTopViewClickLogin];
    }
}
//*********注册按钮*************/
-(SYNoHeightedButton *)registerButton
{
    if (_registerButton == nil) {
        SYNoHeightedButton *registerButton = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:registerButton];
        registerButton.backgroundColor = [UIColor clearColor];
        [registerButton setTitle:@"注册" forState:UIControlStateNormal];
        [registerButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        registerButton.titleLabel.font = [UIFont systemFontOfSize:font16ScreenWRate * LKScreenW];
        registerButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        [registerButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_centerX).offset(rate375(10));
            make.width.equalTo(@(rate375(120)));
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(32)));
                make.top.equalTo(self.iconImageView.mas_bottom).offset(rateX812(81));
            }else{
                make.height.equalTo(@(rate750(32)));
                make.top.equalTo(self.iconImageView.mas_bottom).offset(rate750(81));
            }
        }];
        registerButton.layer.cornerRadius = 3.0;
        registerButton.layer.masksToBounds = YES;
        registerButton.layer.borderColor = [UIColor whiteColor].CGColor;
        registerButton.layer.borderWidth = 1.0f;
        [registerButton addTarget:self action:@selector(registerButtonClick) forControlEvents:UIControlEventTouchDown];
        _registerButton = registerButton;
    }
    return _registerButton;
}
-(void)registerButtonClick
{
    if ([self.delegate respondsToSelector:@selector(mineControllerUnLoginTopView:clickStyle:)]) {
        [self.delegate mineControllerUnLoginTopView:self clickStyle:SYMineUnLoginTopViewClickRegister];
    }
}












@end
